package com.ontheroad.mysql.path.listener;

import com.ontheroad.core.util.GpxUtils;
import com.ontheroad.mysql.path.event.PathEvent;
import com.ontheroad.mysql.path.event.SavePathEvent;
import com.ontheroad.mysql.path.mapper.PathUserMapper;
import com.ontheroad.path.model.Point;
import org.alternativevision.gpx.GPXParser;
import org.alternativevision.gpx.beans.GPX;
import org.alternativevision.gpx.beans.Track;
import org.alternativevision.gpx.beans.Waypoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 根据坐标生成gpx字符串
 * Created by kedong on 2017/8/4 0004.
 */
@Service
public class SavePathListener implements ApplicationListener<SavePathEvent> {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private PathUserMapper mapper;

    @Override
    public void onApplicationEvent(SavePathEvent event) {
        try {
            Integer pathSysId = event.getPathSysId();
            Integer pathUserId = event.getPathUserId();
            Integer userId = event.getUserId();

            String gpxStr = GpxUtils.getGpx(event.getPointList());
        } catch (Exception e) {
            logger.error("保存轨迹点失败", e);
        }
    }
}
